package com.yang.job.infra.exception;


import com.yang.job.client.dto.common.BusinessException;
import com.yang.job.client.dto.common.Response;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = BusinessException.class)
    public Response handleBusinessException(BusinessException e) {
        e.printStackTrace();
        return Response.fail(e.getErrorCode());
    }

    @ExceptionHandler(value = RuntimeException.class)
    public Response handleException(RuntimeException e) {
        e.printStackTrace();
        return Response.fail(e.getMessage());
    }
}

